package com.hrt.manage.stock.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.stereotype.Repository;

import com.hrt.base.BaseDaoImpl;
import com.hrt.bean.StockDetail;
import com.hrt.manage.stock.dao.StockDetailDao;


@Repository
public class StockDetailDaoImpl extends BaseDaoImpl<StockDetail> implements StockDetailDao {

	/***
	 * 根据库单ID取出库单详情列表
	 */
	@Override
	public List<StockDetail> getDetailsByStockId(Long StockId) {
		// TODO Auto-generated method stub
		String hql="select details from StockDetail details where details.stockId="+StockId+" and details.isdelete=0";
		
		return this.getHibernateTemplate().find(hql);
	}
	
	
	/**
	 * 根据库单ID分页取出库单详情列表
	 */
	@SuppressWarnings("deprecation")
	@Override
	public List<StockDetail> getDetialsByStockId(final Long stockId,
			final Integer pageIndex, final Integer pageSize) {
		
		List<StockDetail> result=new ArrayList<StockDetail>();
		String hql = "select result from StockDetail result where result.stockId="
				+ stockId + " and result.isdelete=0";
		result=this.queryByPage(hql, pageIndex, pageSize);
		return result;
	}

	
}
